<script>
	var pnum = {$pnum};
	{if condition="(!isset($search)) AND (!isset($cate_id))"}
	var search = 0;
	var cate_id = 0;
	var goUrl = "/{$Request.module}/news/lst.html?page="+pnum;
	var addUrl = "{:url('news/add')}";
	{elseif condition="(isset($search)) AND ($search)"/}
	var search = {$search};
	var cate_id = 0;
	var goUrl = "/{$Request.module}/news/search.html?page="+pnum;
	var addUrl = "{:url('news/add')}";
	{elseif condition="(isset($cate_id)) AND ($cate_id)"/}
	var cate_id = {$cate_id};
	var search = 0;
	var goUrl = "/{$Request.module}/news/catelist/cate_id/"+cate_id+".html?page="+pnum;
	var addUrl = "/{$Request.module}/news/add/cate_id/"+cate_id;
	{/if}
	
	$(function(){
		$("#checkAll").click(function () {
	        $("input[class='text_id']:checkbox").prop("checked", this.checked);
	    }); 
	});
</script>   

 <script>
 var sy2 = $('td.index:first').text();
 var sy = $('td.index:first').text();

		 var fixHelperModified2 = function(e, tr) {
		      var $originals = tr.children();
		      var $helper = tr.clone();
		      $helper.children().each(function(index) {
		          $(this).width($originals.eq(index).width())
		      });
		      return $helper;
		 },
         
         updateIndex2 = function(e, ui) {
	       	  if(sy2 != sy){
	       		  sy = sy2;
	       	  }
	       	  
              var sort = '';
              var ids = '';
              
              $('td.index', ui.item.parent()).each(function (i) {
           	       if(i==0){
                       $(this).html(sy);
           	       }else{
           		      sy = parseInt(sy)+1;
                      $(this).html(sy);
           	       }
	        	   ids+=$(this).attr('shuxing')+',';
	        	   sort+=$(this).text()+',';
              });
              
              ids = ids.substring(0,ids.length-1);
              sort = sort.substring(0,sort.length-1);
              
              $.ajax({
	              type:'POST',
	              url:"{:url('news/paixu')}",
	              data:{'ids':ids,'sort':sort},
	              dataType:'json',
	              success:function(data){
	            	  layer.msg(data.mess, {icon: 1,time: 1000});
	              },
	              error:function(){
	            	  layer.msg('操作失败或您没有权限，请重试', {icon: 2,time: 2000});
	              }
	          });
         };

 $("#sort tbody").sortable({
     helper: fixHelperModified2,
     stop: updateIndex2
 }).disableSelection();
  </script>              
  
         
                        <table id="sort" class="table table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th style="width:5%"><input type="checkbox" id="checkAll"/></th>
                                    <th style="width:5%">id</th>
                                    <th style="width:25%">文章标题</th>
                                    <th style="width:5%">标识</th>
                                    <th style="width:15%">所属栏目</th>
                                    <th style="width:10%">是否显示</th>
                                    <th style="width:10%">是否推荐</th>
                                    <th style="width:5%" class="index">排序</th>
                                    <th style="width:10%">发布管理员</th>
                                    <th style="width:15%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                            {if condition="$list->isEmpty() == false"}
							{foreach name="list" item="v"}
                                <tr>
                                    <td><input type="checkbox" class="text_id" name="id[]" value="{$v.id}" /></td>
                                    <td>{$v.id}</td>
                                    <td>{$v.ar_title}</td>
                                    <td>
                                        {$v.tag}
                                    </td>
                                    <td>{$v.cate_name}</td>
                                    <td>                                 
                                    {switch name="v.is_show"}
                                    {case value="0"}<button class="btn btn-danger btn-xs" type="button" onclick="changeTableVal({$v.id},'is_show',this);"><i class="fa fa-times"></i></button>{/case}
                                    {case value="1"}<button class="btn btn-primary btn-xs" type="button" onclick="changeTableVal({$v.id},'is_show',this);"><i class="fa fa-check"></i></button>{/case}
                                    {/switch}
                                    </td>
                                    <td>                                 
                                    {switch name="v.is_rem"}
                                    {case value="0"}<button class="btn btn-danger btn-xs" type="button" onclick="changeTableVal({$v.id},'is_rem',this);"><i class="fa fa-times"></i></button>{/case}
                                    {case value="1"}<button class="btn btn-primary btn-xs" type="button" onclick="changeTableVal({$v.id},'is_rem',this);"><i class="fa fa-check"></i></button>{/case}
                                    {/switch}
                                    </td>
                                    <td class="index" shuxing="{$v.id}">{$v.sort}</td>
                                    <td>{$v.en_name}</td>
                                    <td><button type="button" class="btn btn-primary btn-xs" onclick="editar({$v.id},this);"><i class="fa fa-pencil"></i>&nbsp;编辑</button>&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-danger btn-xs" onclick="delone({$v.id},this);"><i class="fa fa-close"></i>&nbsp;删除</button></td>
                                </tr>
							{/foreach}
                            {else/}
							<tr><td colspan="9" style="text-align:center; font-size:14px;">没有找到相关数据</td></tr>
						    {/if}
                            </tbody>
                        </table>
                        <div class="row"><div class="pagination" style="float:right; margin-right:20px;">{$page}</div></div>
                        